/*
 * @Author: 天羽落星辰
 * @Date: 2020-08-17 00:28:01
 * @LastEditors: 天羽落星辰
 * @LastEditTime: 2020-08-17 02:00:15
 * @Description: file content
 */
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        edit: function () {

            require(['jquery-tagsinput'], function () {
                //标签输入
                var elem = "#c-white_list_ip";
                var tags = $(elem);
                tags.tagsInput({
                    width: 'auto',
                    defaultText: '输入后空格确认',
                    minInputWidth: 110,
                    height: '100px',
                    placeholderColor: '#999',
                    onChange: function (row) {
                        if (typeof callback === 'function') {

                        } else {
                            $(elem + "_addTag").focus();
                            $(elem + "_tag").trigger("blur.autocomplete").focus();
                        }
                    },
                    // autocomplete: {
                    //     url: 'cms/tags/autocomplete',
                    //     minChars: 1,
                    //     menuClass: 'autocomplete-tags'
                    // }
                });
            });

            // Form.api.bindevent($("form[role=form]"));

            Form.api.bindevent($("form[role=form]"), function (data, ret) {
                console.log(ret)
                if (ret.code == 1) {
                    Layer.alert(ret.msg, function () {
                        location.href = ret.url;
                    });
                }
                return false;
            });
        }
    };
    return Controller;
});